<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AppAction
 *
 * @author YL-Z0016
 */
class AppAction {
    /**
     *获取全部的应用 
     */
    public function getAllApp(){
        $AppModel = getModel('AppModel');
        $rs = $AppModel->getAllApp();
        if($rs){
            return $rs;
        }else{
            return array();
        }
    }
    /**
     *用户获取自己已经条件的应用
     * @return type 
     */
    public function getUserApp(){
        $uid = intval(post('uid'));
        if($uid > 0){
            $AppModel = getModel('AppModel');
            $rs = $AppModel->getApps($uid);
            if($rs){
                return $rs;
            }else{
                return array();
            }
        }
        return Error::PARAM_ABSENCE;
    }
    /**
     *用户添加应用
     * @return type 
     */
    public function userAddApp(){
        $uid = intval(post('uid'));
        $appid = intval(post('appid'));
        if($uid > 0 AND $appid > 0){
            $AppModel = getModel('AppModel');
            $rs = $AppModel->userAddApp($uid,$appid);
            if($rs){
                return array('addok' => 1);
            }else{
                return Error::OPTION_ERROR;
            }
        }
        return Error::PARAM_ABSENCE;
    }
    /**
     *用户删除应用操作
     * @return type 
     */
    public function userDelApp(){
        $uid = intval(post('uid'));
        $appid = intval(post('appid'));
        if($uid > 0 AND $appid > 0){
            $AppModel = getModel('AppModel');
            $rs = $AppModel->userDelApp($uid,$appid);
            if($rs){
                return array('delok' => 1);
            }else{
                return Error::OPTION_ERROR;
            }
        }
        return Error::PARAM_ABSENCE;
    }
}

?>
